import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ball_lion/service/config_service.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/resources/styles.dart';
import 'package:ball_lion/utils/widget_utils.dart';
import 'package:ball_lion/widgets/base/wqs_widget.dart';

import 'package:ball_lion/widgets/base/wqs_text.dart';

class LqOddsTypePage extends StatefulWidget {
  const LqOddsTypePage({super.key});

  @override
  State<LqOddsTypePage> createState() => _LqOddsTypePageState();
}

class _LqOddsTypePageState extends State<LqOddsTypePage> {
  LqConfig config = Get.find<ConfigService>().lqConfig;
  ConfigService configService = Get.find<ConfigService>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Styles.appBar(title: QsText('篮球指数类型')),
      backgroundColor: Colours.scaffoldBg,
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 8),
        child: ListView(children: [
          SizedBox(height: 10),
          Styles.card(
              child: Column(
            children: [
              cell(0),
              QsWidget.seperateLine(),
              cell(1),
              QsWidget.seperateLine(),
              cell(2)
            ],
          ))
        ]),
      ),
    );
  }

  Widget cell(int index) {
    return QsWidget.selectCell(
        configService.lqOddsType[index], config.lqList7.contains(index),
        onTap: () {
      if (config.lqList7.contains(index)) {
        config.lqList7.remove(index);
      } else {
        config.lqList7.add(index);
      }
      config.lqList7.sort((a, b) => a.compareTo(b));
      update();
      configService.update(ConfigType.lqList7, config.lqList7);
    });
  }
}
